<?php 
global $_GPC, $_W;
$system=pdo_get('wxc_system',array('uniacid'=>$_W['uniacid']));
$GLOBALS['frames'] = $this->getMainMenu();
$operation = !empty($_GPC['op']) ? $_GPC['op'] : 'display';
$status=$_GPC['status'];
load()->func('tpl');
$pageindex = max(1, intval($_GPC['page']));
$pagesize=10;
$where=' WHERE a.uniacid=:uniacid and a.order_id=:id';
$sql="SELECT a.*,b.title,c.nickname,c.img FROM ".tablename('wxc_task'). " a"  . " left join " . tablename("wxc_order") . " b on a.order_id=b.id ". " left join " . tablename("wxc_users") . " c on a.u_id=c.id " .$where." ORDER BY a.create_time DESC";
$data[':uniacid']=$_W['uniacid'];
$data[':id']=$_GPC['id'];
$total=pdo_fetchcolumn("SELECT a.*,b.title,c.nickname,c.img FROM ".tablename('wxc_task'). " a"  . " left join " . tablename("wxc_order") . " b on a.order_id=b.id ". " left join " . tablename("wxc_users") . " c on a.u_id=c.id " .$where." ORDER BY a.create_time DESC",$data);
// print_r(json_encode($total));die;
$select_sql =$sql." LIMIT " .($pageindex - 1) * $pagesize.",".$pagesize;
$list=pdo_fetchall($select_sql,$data);
// print_r(json_encode($list));die;
$pager = pagination($total, $pageindex, $pagesize);
if($operation=='delete'){
	$res=pdo_delete('wxc_task',array('id'=>$_GPC['id']));
	if($res){
		message('删除成功',$this->createWebUrl('check',array()),'success');
	}else{
		message('删除失败','','error');
	}
}
foreach ($list as $key => $value) {
	$create_time = strtotime($value['create_time']);
	$limit_time = 2*24*60*60;
	if (time()-$create_time>$limit_time && $value['status'] == '0') {
		$res = pdo_update('wxc_task',array('status'=>'1'),array('id'=>$_GPC['id']));
	}if($_GPC['op']=='change'){
		   $res=pdo_update('wxc_task',array('status'=>$_GPC['status']),array('id'=>$_GPC['id']));
		    if($res){
		        message('操作成功',$this->createWebUrl('check',array()),'success');
		    }else{
		        message('操作失败','','error');
		    }
		}
}
include $this->template('web/check');

 ?>